package API;

import java.util.Scanner;

public class Java04 {
    public static void main(String[] args) {
        //API案例：用户登录案例
        for (int i = 0; i<3; i++) {
            System.out.print("请输入您的用户名：");
            Scanner sc = new Scanner(System.in);
            String name = sc.next();
            System.out.print("请输入您的密码：");
            String password = sc.next();
            //调用登录方法判断用户是否登陆成功
            boolean rs = login(name,password);
            if (rs == true ){
                System.out.println("登陆成功");
                break;
            }else {
                System.out.println("登陆失败，请核验用户密码");
            }
        }

    }
    //定义一个登陆方法
    public static boolean login(String name,String password){
        //初始化正确的账号密码
        String  okname = "itheima";
        String okpassword = "123456";
        //对用户输入的账号密码进行验证
        return okname.equals(name) && okpassword.equals(password);
    }
}
